.pragma library

//声明是共享库，没有上面这句，则每个包含此js的组件，都独立拷贝了一份此js的所有变量。

var component
var sprite
function createSpriteObjects() {
    component=Qt.createComponent("Sprite.qml")
    if(component.status===Component.Ready){
        finishCreation()
    }else{
        component.statusChanged.connect(finishCreation)
    }
}
function finishCreation(){
    if(component.status===Component.Ready){
        sprite=component.createObject(root,{"x":100,"y":100})
        if(sprite===null){
            console.log("Error creating object")
        }
    }else if(component.status===Component.Error){
        console.log("Error loading component:",component.errorString())
    }
}

